home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / font.cc < prev    next >
C/C++ Source or Header  |  1995-06-06  |  1KB  |  71 lines

  1. /*    Copyright Alex Hornby 1994/1995. All rights reserved.
  2.      See file README for details
  3. */
  4. #include "btypes.h"
  5. #include "palette.h"
  6. #include "gif.h"
  7. #include "asmblock.h"
  8. #include "screendefs.h"
  9. #include "alopen.h"
  10. #include <stdio.h>
  11.  
  12. byte *fontptr;
  13.  
  14. void
  15. fcutblock( void* source, void* dest, unsigned int adj, unsigned int width, unsigned int height)
  16. {
  17.         for(int y=0; y<height; y++)
  18.         {
  19.                 for(int x=0; x<width ;x++)
  20.                         *( ((byte*)dest)++ )=*( ((byte*)source)++ );
  21.                 (byte*)source+=adj;
  22.         }
  23. }
  24.  
  25.  
  26. void fontinit(void)
  27. {
  28.     byte    *t, *p;
  29.     Gif gif;
  30.     int w;
  31.     FILE* fp=alopen("gfx/font.gif","rb");
  32.     gif.Load(fp);
  33.  
  34.     t = fontptr = new byte [8192]; // reserve 8k
  35.     w=gif.getWidth();
  36.     p=gif.getPtr();
  37.         int adj=w-8;
  38.  
  39.     for(int c=0; c<31; c++)
  40.         fcutblock(p,t+=64,adj,8,8);
  41.  
  42.     for(int r=0;r<3;r++)
  43.     {
  44.          for(c=0; c<32; c++)
  45.             fcutblock(p+ (r*w*8) + c * 8, 
  46.                     t+=64, adj, 8, 8);
  47.     }
  48. }
  49.  
  50. void printor(char *s, void *dest, int x , int y)
  51. {
  52.     int c=0;
  53.     while( *s != 0 )
  54.     {
  55.         orpasteblock(fontptr+64*(*s), ((byte*)dest)+c*8+x+y*SCREENWIDTH, 8, 8);  
  56.         s++;
  57.         c++;
  58.     }  
  59. }
  60.  
  61. void print(char *s, void *dest, int x , int y)
  62. {
  63.     int c=0;
  64.     while( *s != 0 )
  65.     {
  66.         pasteblock(fontptr+64*(*s), ((byte*)dest)+c*8+x+y*SCREENWIDTH, 8, 8);  
  67.         s++;
  68.         c++;
  69.     }  
  70. }
  71.